package com.clear.club.circle.server.config;

import com.clear.club.circle.api.vo.ShareCircleVO;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;
import java.util.List;

@Configuration
public class CaffeineConfig {

    @Bean
    public Cache<String, List<ShareCircleVO>> circleCache(){
        return Caffeine.newBuilder()
                .initialCapacity(1)
                .maximumSize(20)    // 缓存大小上限
                .expireAfterAccess(Duration.ofSeconds(30))  // 缓存有效期为30s
                .build();
    }

}
